package com.lighting.module4.controller;

import com.lighting.module4.dto.Calculator;
import com.lighting.module4.service.CalculatorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class CalculatorController {
    //反转控制-依赖注入
    @Autowired
    CalculatorService[] array;

    //还款总额
    @RequestMapping("/cal")
    @ResponseBody
    String[] cal(int type, Calculator c){
        return array[type].cal(c);
    }

    //还款详情
    @RequestMapping("/details")
    @ResponseBody
    String[][] ShowDetails(int type, Calculator c){
        return array[type].details(c);
    }
}
